// house_pkg/pages/room/index.ts
Page({

  /**
   * 页面的初始数据
   */
  data: {
    point: '',
    building: '',
    rooms: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad ({ point, building }) {
    this.fake(point, building)
  },
  fake (point, building) {
    // 伪造房间号和楼层号
    // const rooms = [303,202,505,601]

    // 伪造楼层
    const size = Math.floor(Math.random() * 5) + 6
    const rooms = []
    for (let i = 0; i < size; i++) {
      // 随机楼号
      const floor = Math.floor(Math.random() * 20) + 1
      // 501   1202    303
      const No = Math.floor(Math.random() * 3) + 1
      // [2,0,1] ===> 201
      const room = [floor, 0, No].join('')
      // 去重
      if (rooms.includes(room)) continue
      rooms.push(room)
    }
    console.log('rooms', rooms)
    this.setData({
      point,
      building,
      rooms
    })
  },
  goForm (ev) {
    // 获取小区和楼栋信息
    const { point, building } = this.data
    wx.navigateTo({
      url: `/house_pkg/pages/form/index?point=${point}&building=${building}&room=${ev.mark.room}`,
    })
  }

})